
#include "xz_common.h"
#include "xz_config.h"
#include "app_nfc.h"
#include "app_adc.h"

#include "system_clock.h"



void setup()
{

    SystemClock_HSI16_Config();

    pinMode(LED0, OUTPUT);

    digitalWrite(LED0, LOW);
    pinMode(LED1, OUTPUT);
    digitalWrite(LED1, LOW);


    PRINT_DEBUG("System Init done!\n");

    PRINT_INFO("......\n");
    PRINT_DEBUG("......\n");

    // delay(100);
    ADC_Init();
    uint32_t EPD_Vol = 2 * ADC_READ_Voltage(EPD_ADC);
    PRINT_INFO("%dmv\n", EPD_Vol);





    MX_NFC_Init();


#if (1)
    // #if (EPD_COLOR == 3)
    PRINT_INFO("time:%d\n", millis());
    eink_inti();
    PRINT_INFO("time:%d\n", millis());

#endif

    PRINT_INFO("EPD_model:%s....\n", EPD_MODEL);
    PRINT_INFO("time:%d\n", millis());
}

void loop()
{
    // put your main code here, to run repeatedly:

    MX_NFC_Process();
    ADC_Volt_Process();
    // delay(10);
    // HAL_PWR_EnterSTANDBYMode();
    // HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON,PWR_SLEEPENTRY_WFI);
    // HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON,PWR_SLEEPENTRY_WFI);
#ifdef SLEEP_ENABLE
    HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFE);
#else
    delay(1);
#endif // SLEEP_ENABLE
}

void HardFault_Handler(void)
{
    /* Go to infinite loop when Hard Fault exception occurs */
    PRINT_INFO("@@@@@\n");
    while (1)
    {
    }
}